package com.zzk.lanouhn.myapplication1.adapters;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jude.rollviewpager.adapter.StaticPagerAdapter;
import com.squareup.picasso.Picasso;
import com.zzk.lanouhn.myapplication1.activity.FindLnuBoDetails;
import com.zzk.lanouhn.myapplication1.modles.FindLunBoModle;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lanouhn on 16/9/1.
 */
public class FindLunBoAdapter extends StaticPagerAdapter{
    private Context mContext;
   private List<FindLunBoModle> lunBoModles=new ArrayList<>();

    public FindLunBoAdapter(Context mContext, List<FindLunBoModle> lunBoModles) {
        this.mContext = mContext;
        this.lunBoModles = lunBoModles;
    }

    @Override
    public View getView(ViewGroup container, int position) {
        ImageView imageView=new ImageView(container.getContext());
        Picasso.with(mContext).load(lunBoModles.get(position).getImage_url()).into(imageView);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(mContext, FindLnuBoDetails.class);
                mContext.startActivity(intent);
            }
        });


        return imageView;
    }

    @Override
    public int getCount() {
        return lunBoModles.size();
    }
}
